import storage from '@/libs/storage'
import localeZhCN from '@/locale/zh-CN'
import localeEn from '@/locale/en'

const isZh = storage.getLocal('language') === 'zh';
let locale = isZh ? localeZhCN : localeEn;

const keyMap = {
    // 交易方式
    payChannelList: [
        { value: '1', label: 'M Lhuillier' },
        { value: '3', label: 'Palawan Pawnshop' },
        { value: '4', label: 'ECPay' },
        { value: '5', label: 'Bank' },
        { value: '6', label: 'GCash' },
        { value: '7', label: 'Coins' },
        { value: '9', label: 'RD Pawnshop' },
        { value: '8', label: 'Paymaya' },
        { value: '15', label: 'GrabPay' },
        { value: '10', label: '7-11' },
        { value: '19', label: 'ShopeePay' },
        { value: '50', label: 'Instapay' },
        { value: '60', label: 'QR' },
        { value: '100', label: 'BALANCE' },
        { value: '101', label: 'Derate' },
        { value: '102', label: 'Repay Coupon' },
        { value: '99', label: 'Others' },
    ],
    // 放款方式 active是否在用
    loanChannel: [
        { value: '1', label: 'M Lhuillier', active: 1 },
        { value: '3', label: 'Palawan Pawnshop', active: 1 },
        { value: '4', label: 'ECPay', active: 0 },
        { value: '5', label: 'Bank', active: 1 },
        { value: '6', label: 'GCash', active: 1 },
        { value: '7', label: 'Coins', active: 1 },
        { value: '9', label: 'RD Pawnshop', active: 1 },
        { value: '8', label: 'Paymaya', active: 1 },
        { value: '15', label: 'GrabPay', active: 1 },
        { value: '10', label: 'Seven Corporation' },
        { value: '100', label: 'BALANCE', active: 0 },
        { value: '99', label: 'Others', active: 0 },
    ],
    //节点名称
    triggerNode:[
        { value: '1', label: locale.operation.loginSuccess },
        { value: '2', label: locale.operation.repaySuccess  },

    ] ,
    //优惠券状态
    aouponStatus:[
        { value: '0', label: locale.common.close },
        { value: '1', label: locale.common.open  },
    ],
    // 线下放款渠道
    offlineLoanChannelName: ['Bank', 'GCash', 'Coins', 'Paymaya', 'GrabPay'],
    // 线下放款渠道值
    offlineLoanChannelValue: [5, 6, 7, 8, 15],
    // 退款渠道
    refundChannel: [
        { value: '5', label: 'Bank' },
        { value: '6', label: 'GCash' },
        { value: '7', label: 'Coins' },
        { value: '8', label: 'Paymaya' },
        { value: '15', label: 'GrabPay' },
    ],
    // 收款类型
    collectionType:[
        {value:'1',label:locale.common.normalCollection},//正常放款
        {value:'2',label:locale.common.extensionCollection}//展期放款
    ],
    //展期放款
    loanType:[
        {value:'1',label:locale.common.normalLend},//正常放款
        {value:'2',label:locale.common.extensionLoan}//展期放款
    ],
    //展期还款类型
    repaymentType:[
        {value:'1',label:locale.common.normalRepay },//正常放款
        {value:'2',label:locale.common.extensionRepay }//展期放款
    ],
    // 交易类型
    tradeTypeList: [
        { value: '1',label: locale.common.loan }, // 放款
        { value: '2',label: locale.common.loanFee }, // 放款手续费
        { value: '3',label: locale.common.repayFee }, // 还款手续费
        { value: '4',label: locale.finance.lendingServiceFee }, // 放款扣服务费
        { value: '5',label: locale.finance.repaymentPrincipal }, // 还款本金
        { value: '6',label: locale.finance.repaymentInterest }, // 还款扣利息
        { value: '7',label: locale.finance.repaymentServiceFee }, // 还款扣服务费
        { value: '8',label: locale.finance.repaymentLateFee }, // 还款滞纳金
        { value: '9',label: locale.finance.repaymentPenaltyInterest }, // 还款罚息
        { value: '10',label: locale.finance.loanTax }, // 放款税收
        { value: '11',label: locale.finance.repaymentTax }, // 还款税收
        { value: '12',label: locale.finance.loanInterest }, // 放款扣利息
        { value: '13',label: locale.finance.platformAdditionalIncome }, // 平台额外收益
        { value: '14',label: locale.finance.ledger }, // 平账
        { value: '15',label: locale.finance.offlineReturn }, // 线下退回
        { value: '16',label: locale.finance.returnFee }, // 退回手续费
        { value: '17',label: locale.common.refund }, // 退款
        { value: '18',label: locale.common.refundFee }, // 退款手续费
        { value: '19',label: locale.common.extensionAmount2 }, // 展期费
        { value: '20',label: locale.common.extensionFee }, // 展期手续费
        { value: '21',label: locale.common.extensionTax }, // 展期税收
        { value: '22',label: locale.operation.repaymentCoupon }, // 还款优惠券
    ],
    // 营销类型
    marketingType: [
        { value: '1', label: locale.salesManage.customerReLoan }, // 还款未复借
        { value: '2', label: locale.salesManage.whitelistApplication }, // 白名单用户
        { value: '3', label: locale.salesManage.firstLoanFourDay}, // 首次放款四天

    ],
    // 优惠券类型
    couponType: [
        { value: '1', label: locale.operation.repaymentCoupon }, // 还款优惠券
        // { value: '2', label: locale.operation.interestFreeCoupons }, // 免息优惠券
    ],
};
// 处理数据，是返回列表还是返回数据转换label
function HandleData(list) {
    return (type, isString = true) => {
        if (type !== undefined) {
            if (isString) type = String(type);
            let res = '';
            list.forEach(item => {
                if (item.value === type) {
                    res = item.label;
                }
            });
            return res;
        } else {
            return list;
        }
    }
}

export default {
    overdueType: [
        { value: '', label: '全部' },
        { value: 'S', label: '未逾期' },
        { value: 'S1', label: '0-15天' },
        { value: 'S2', label: '16-30天' },
        { value: 'M2', label: '31-60天' },
        { value: 'M3', label: '60-90天' },
        { value: 'M3+', label: '90天以上' },
    ],
    payChannelList: keyMap.payChannelList,
    loanChannel: keyMap.loanChannel,
    refundChannel: keyMap.refundChannel,
    loanType:keyMap.loanType,
    collectionType:keyMap.collectionType,
    repaymentType:keyMap.repaymentType,
    type: [
        { value: '-1', label: '全部' },
        { value: '0', label: '个人' },
        { value: '1', label: '商家' }
    ],
    // 本人手机号、本人公司电话、本人借款卡预留号码、本人还款卡预留号码、配偶、父母、亲戚、兄弟、姐妹、同事、朋友、其他
    relationshipMap: {
        self: '本人手机号',
        company: '本人公司电话',
        borrowCard: '本人借款卡预留号码',
        repayCard: '本人还款卡预留号码',
        mate: '配偶',
        parent: '父母',
        relatives: '亲戚',
        brother: '兄弟',
        sister: '姐妹',
        workmate: '同事',
        schoolmate: '同学',
        friends: '朋友',
        other: '其他',
    },
    repayStatusList: [
        { value: '', label: locale.common.all },// 全部
        { value: '0', label: locale.finance.repaying },// 还款中
        { value: '1', label: locale.finance.repaySuccess },// 还款成功
        { value: '2', label: locale.finance.repayFail },// 还款失败
        { value: '3', label: locale.finance.applying },// 申请中
    ],
    channelTypeList: [
        { value: '', label: '全部渠道' },
        { value: 'ltqb', label: '老铁钱包' },
        { value: 'jlqb', label: '锦鲤钱包' },
    ],
    delayType: [
        { value: '', label: '全部状态' },
        { value: '1', label: '支付成功' },
        { value: '2', label: '支付失败' },
        { value: '3', label: '申请中' },
    ],
    switchTriggerNode(channel){
        console.warn(channel ,locale.operation.loginSuccess)
        switch (channel) {
            case 1:
                return locale.operation.loginSuccess;
            case 2:
                return locale.operation.repaySuccess;
            default:
                return ''
        }
    },
    // 交易状态
    transStatusType(transStatus){
        switch (transStatus) {
            case '0':
                return '支付中';
            case '1':
                return '支付成功';
            case '2':
                return '支付失败';
            case '3':
                return '申请中';
            default:
                return '';
        }
    },
    switchProductName(name){
        let domain = storage.get('user').domain
        let result =name;
        if(domain=='Logicash'){
            if(name=='Logicash-A'){
                result = 'Topeso-A'
            };
            if(name=='Logicash-B'){
                result = 'Topeso-B'
            };
            if(name=='Logicash-C'){
                result = 'Topeso-C'
            };
            if(name=='Logicash-D'){
                result = 'Topeso-D'
            };
        }
        return result
    },
    switchAppName(name){
        let domain = storage.get('user').domain
        let result =name;
        if(domain=='GoalMete'||domain=='Realcash'){
            if(name=='PureCash'){
                result = 'Plan A'
            };
            if(name=='SugerCoin'){
                result = 'Plan B'
            };
            if(name=='SugerPocket'){
                result = 'Plan C'
            };
            if(name=='Realcash'){
                result = 'Plan D'
            };
            if(name=='Keypeso'){
                result = 'Plan E'
            };
        };
        if(domain=='Logicash'){
            if(name=='Logicash'){
                result = 'Topeso'
            };
        }
        return result
    },
    // 还款状态
    repayStatusType(repayStatus){
        switch (repayStatus + '') {
            case '0':
                return locale.finance.repaying;// 还款中
            case '1':
                return locale.finance.repaySuccess;// 还款成功
            case '2':
                return locale.finance.repayFail;// 还款失败
            case '3':
                return locale.finance.applying;// 申请中
            default:
                return repayStatus;
        }
    },
    telRoleList: [
        { value: '1', label: '电核专员' },
        { value: '2', label: '电核主管' },
        { value: '3', label: '电核经理' },
    ],
    relationshipData: [
        {name:locale.common.relationShip.Father,code: 'Father'},
        {name:locale.common.relationShip.Mother,code: 'Mother'},
        {name:locale.common.relationShip.Spouse,code: 'Spouse'},
        {name:locale.common.relationShip.Children,code: 'Children'},
        {name:locale.common.relationShip.BrothersAndSisters,code: 'BrothersAndSisters'},
        {name:locale.common.relationShip.Friend,code: 'Friend'},
        {name:locale.common.relationShip.Colleague,code: 'Colleague'},
        {name:locale.common.relationShip.Classmate,code: 'Classmate'},
        {name:locale.common.relationShip.Self,code: 'Self'},
        {name:locale.common.relationShip.Company,code: 'Company'},
        {name:locale.common.relationShip.WhatsApp,code: 'WhatsApp'},
        {name:locale.common.relationShip.Others,code: 'Others'},

    ],
    switchLoanChannel(channel) {
        let res = channel;
        const list = keyMap.payChannelList;
        for (let i = 0; i < list.length; i++) {
            if (list[i].value === String(channel)) {
                res = list[i].label;
                break;
            }
        }
        return res;
    },
    loanChannelList: [
        { value: '2', label: 'SkyPay' },
        { value: '-2', label: 'MSP' },
        { value: '3', label: 'AUB' },
        { value: '4', label: 'Xendit' },
        { value: '1', label: 'Wallyt' },
        { value: '5', label: 'Payso' },
    ],
    SwitchRepaymentType(channel){
        switch (channel + '') {
            case '1':
                return locale.common.normalRepay;
            case '2':
                return locale.common.extensionRepay;
            default:
                return ''
        }
    },
    SwitchCollectionType(channel){
        switch (channel + '') {
            case '1':
                return locale.common.normalCollection;
            case '2':
                return locale.common.extensionCollection;
            default:
                return ''
        }
    },
    SwitchLoanType(channel){
        switch (channel + '') {
            case '1':
                return locale.common.normalLend;
            case '2':
                return locale.common.extensionLoan;
            default:
                return ''
        }
    },
    SwitchChannelCompany(channel) {
        switch (channel + '') {
            case '2':
                return 'SkyPay';
            case '-2':
                return 'MSP';
            case '3':
                return 'AUB';
            case '1':
                return 'Wallyt';
            case '4':
                return 'Xendit';
            case '5':
                return 'Payso';
            default:
                return '';
        }
    },
    switchUserType(type) {
        switch (type + '') {
            case '0':
                return locale.common.newUser;// 新户
            case '1':
                return locale.common.secNewUser;// 次新户
            case '2':
                return locale.common.oldUser;// 老户
            default:
                return type;
        }
    },
    switchLeadingActionType(type) {
        console.warn(type,'dasdsad')
        switch (type + '') {
            case '0':
                return locale.finance.manualLending;// 手动放款
            case '1':
                return locale.finance.autoLending;// 自动放款
            case '2':
                return locale.common.offlineLoan;// 线下放款
            default:
                return type;
        }
    },
    changeType(type) {
        switch (type + '') {
            case '0':
                return locale.common.collectMoney;// 入账
            case '1':
                return locale.common.payMoney;// 出账
            default:
                return type;
        }
    },
    tradeTypeList: keyMap.tradeTypeList,
    tradeType(type) {
        let res = type;
        const list = keyMap.tradeTypeList;
        for (let i = 0; i < list.length; i++) {
            if (list[i].value === String(type)) {
                res = list[i].label;
                break;
            }
        }
        return res;
    },
    ledgerType(type) {
        switch (type + '') {
            case '0':
                return locale.finance.publicTransfer;// 对公转账
            case '1':
                return locale.finance.reducePenaltyInterest;// 抹罚息
        }
    },
    activeStatus(type) { // 激活状态
        switch (type + '') {
            case '0':
                return locale.collection.activated;// 已启用
            case '1':
                return locale.collection.closed;// 已关闭
        }
    },
    userTypeTelSales(type) {
        switch (type + '') {
            case '':
                return locale.common.all;//全部
            case '0':
                return locale.common.newUser;//新户
            case '1':
                return locale.common.secNewUser;//次新户
            case '2':
                return locale.common.oldUser;//老户
            case '3':
                return locale.common.unregistered;//未注册
            default:
                return type;
        }
    },
    couponType: new HandleData(keyMap.couponType),
    marketingType: new HandleData(keyMap.marketingType),
    offlineLoanChannelName: keyMap.offlineLoanChannelName,
    offlineLoanChannelValue: keyMap.offlineLoanChannelValue,
    triggerNode:keyMap.triggerNode,
    aouponStatus:keyMap.aouponStatus
};
